<?php

/**
search form for invoice
class: myInvoiceSearchForm
author: milwell
date: 2008-11-30 13:51
*/

  class myReceivableSearchForm extends sfForm{
    
    public function configure(){
    
      $this->setWidgets(
        array(
          'report_type' => 
            new sfWidgetFormSelect(
              array(
                'choices'=>
                  array(
                    'as of'=>'as of',
                    'date range'=>'date range',
                  ),
              )
            ),
          'date_from' => new sfWidgetFormDate(),
          'date_to' => new sfWidgetFormDate(),
          'detail'=> new sfWidgetFormInputCheckbox(),
        )
      );
      
      
      $this->setValidators(array(
        'date_from' => new sfValidatorDate(array('required'=>false,)),
        'date_to' => new sfValidatorDate(array('required'=>false,)),
      ));
      
      $this->widgetSchema->setLabels(
        array(
          'report_type' => 'Report Type:',
          'date_from' => 'From/As of:',
          'date_to' => ' to ',
          'detail' => ' Detail? ',
        )
      );
      
      $years = range(date('Y')-50,date('Y')+1);
      $this->widgetSchema['date_from']->setOption('years',array_combine($years,$years));
      $this->widgetSchema['date_to']->setOption('years',array_combine($years,$years));
      
      $this->widgetSchema['detail']->setOption('value_attribute_value','Y');
      
      $this->widgetSchema->setNameFormat('skey_receivable[%s]');
      
    }
    
    public function renderFields(){?>
      <tr>
        <th class="field">
          <?php echo $this['report_type']->renderLabel()?>
        </th>
        <td>
          <?php echo $this['report_type'];?>
        </td>
        <th class="field">
          <?php echo $this['date_from']->renderLabel()?>
        </th>
        <td>
          <?php echo $this['date_from'];?>
        </td>
        <th class="field">
          <?php echo $this['date_to']->renderLabel()?>
        </th>
        <td>
          <?php echo $this['date_to']?>
        </td>
        <th class="field">
          <?php echo $this['detail']->renderLabel()?>
        </th>
        <td>
          <?php echo $this['detail']?>
        </td>
      </tr>
    <?php }
    
  }


?>